import 'package:finance_app/src/entities/company_financial_year_entity.dart';

companyFinancialYearEntityFromJson(CompanyFinancialYearEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['start_date'] != null) {
		data.startDate = json['start_date'].toString();
	}
	if (json['end_date'] != null) {
		data.endDate = json['end_date'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['is_close'] != null) {
		data.isClose = json['is_close'] is String
				? int.tryParse(json['is_close'])
				: json['is_close'].toInt();
	}
	if (json['current_year_earning_journal_id'] != null) {
		data.currentYearEarningJournalId = json['current_year_earning_journal_id'] is String
				? int.tryParse(json['current_year_earning_journal_id'])
				: json['current_year_earning_journal_id'].toInt();
	}
	if (json['less_dividend_journal_id'] != null) {
		data.lessDividendJournalId = json['less_dividend_journal_id'] is String
				? int.tryParse(json['less_dividend_journal_id'])
				: json['less_dividend_journal_id'].toInt();
	}
	if (json['is_current_year'] != null) {
		data.isCurrentYear = json['is_current_year'];
	}
	return data;
}

Map<String, dynamic> companyFinancialYearEntityToJson(CompanyFinancialYearEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['start_date'] = entity.startDate;
	data['end_date'] = entity.endDate;
	data['status'] = entity.status;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['is_close'] = entity.isClose;
	data['current_year_earning_journal_id'] = entity.currentYearEarningJournalId;
	data['less_dividend_journal_id'] = entity.lessDividendJournalId;
	data['is_current_year'] = entity.isCurrentYear;
	return data;
}